package com.ruoyi.module.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.module.mapper.ExamQuestionsMapper;
import com.ruoyi.module.domain.ExamQuestions;
import com.ruoyi.module.service.IExamQuestionsService;

/**
 * 考试题目Service业务层处理
 *
 * @author fubojin
 * @date 2025-03-05
 */
@Service
public class ExamQuestionsServiceImpl implements IExamQuestionsService
{
    @Autowired
    private ExamQuestionsMapper examQuestionsMapper;

    /**
     * 查询考试题目
     *
     * @param id 考试题目主键
     * @return 考试题目
     */
    @Override
    public ExamQuestions selectExamQuestionsById(Long id)
    {
        return examQuestionsMapper.selectExamQuestionsById(id);
    }

    /**
     * 查询考试题目列表
     *
     * @param examQuestions 考试题目
     * @return 考试题目
     */
    @Override
    public List<ExamQuestions> selectExamQuestionsList(ExamQuestions examQuestions)
    {
        return examQuestionsMapper.selectExamQuestionsList(examQuestions);
    }

    /**
     * 新增考试题目
     *
     * @param examQuestions 考试题目
     * @return 结果
     */
    @Override
    public int insertExamQuestions(ExamQuestions examQuestions)
    {
        examQuestions.setCreateTime(DateUtils.getNowDate());
        return examQuestionsMapper.insertExamQuestions(examQuestions);
    }

    /**
     * 修改考试题目
     *
     * @param examQuestions 考试题目
     * @return 结果
     */
    @Override
    public int updateExamQuestions(ExamQuestions examQuestions)
    {
        examQuestions.setUpdateTime(DateUtils.getNowDate());
        return examQuestionsMapper.updateExamQuestions(examQuestions);
    }

    /**
     * 批量删除考试题目
     *
     * @param ids 需要删除的考试题目主键
     * @return 结果
     */
    @Override
    public int deleteExamQuestionsByIds(Long[] ids)
    {
        return examQuestionsMapper.deleteExamQuestionsByIds(ids);
    }

    /**
     * 删除考试题目信息
     *
     * @param id 考试题目主键
     * @return 结果
     */
    @Override
    public int deleteExamQuestionsById(Long id)
    {
        return examQuestionsMapper.deleteExamQuestionsById(id);
    }

    @Override
    public List<ExamQuestions> selectQuestionsCategoryList(Integer examType, Integer choice, Integer choiceRepeat, Integer judge) {

        List<ExamQuestions> examQuestions = examQuestionsMapper.selectQuestionsCategoryList(examType, choice, choiceRepeat, judge);

//        List<ExamQuestions> collect = examQuestions.stream().filter(c -> c.getType() == 1).collect(Collectors.toList());
//        List<ExamQuestions> collect = examQuestions.stream().filter(c -> c.getType() == 1).collect(Collectors.toList());
//        List<ExamQuestions> collect = examQuestions.stream().filter(c -> c.getType() == 1).collect(Collectors.toList());


        return examQuestions;
    }
}
